import os
import platform

class MsgGenerator:
    def generate_protobuf_cpp_files(self):
        files = os.listdir('./protobuf')
        for file in files:
            file_path = os.path.join('./protobuf', file)
            if not os.path.isdir(file_path):
                if file_path.endswith('.proto'):
                    os_type = platform.system()
                    if os_type =="Windows":
                        os.system('.\protoc.exe --proto_path=.\protobuf --cpp_out=.\common\protobuf_generated ' + file_path)
                    else:
                        os.system('protoc --proto_path=./protobuf --cpp_out=./common/protobuf_generated ' + file_path)

if __name__ == '__main__':
    generator = MsgGenerator()
    generator.generate_protobuf_cpp_files()
